    var append = new Array();

    $(document).ready(function(){   
        setStyle("mainforum");
        
        $.mobile.loading('show');   
        var http = "http://anibox.me/api.php?task=get_forums&parent=0";
        $.getJSON(http, parseJson);
    });  
    
    
    //parse json and show it in collapse head
    function parseJson(data){
        for (var i in data) {
            append[i] = $('<div id="'+i+'" data-role="collapsible"></div>');
            append[i].append('<h1 class="h_style"><div class="h_style">' + data[i].title + '</div></h1>');            
        }
        for (var i in data){
            var http = "http://anibox.me/api.php?task=get_forums&parent="+data[i].id;
            window.parent.setTimeout($.getJSON(http, parseJsonInCol),0);
        }
        //$.mobile.loading('hide');
    }
    
    //parse json and show it in list
    var count=0;
    function parseJsonInCol(data){
        var list = $('<ul data-role="listview" id="list'+count+'"><ul>');
        var buf;
        for(var j in data){
            buf = '<li id="'+data[j].id+'" ';
            
            if(data[j].total_topics != 0)
                buf += ' onclick="liOnClick(this.id)"';
            
            buf +=
                '><div id="div_style">'+data[j].title+'</div>' +
                ' Тем: '+data[j].total_topics +
                ' Сообщений: '+data[j].total_answers+'</p>' +
                '</li>';
            list.append(buf);
        }
        
        append[count].append(list);
        $('#collaps').append(append[count]);
        count++;
        $('#collaps').collapsibleset('refresh');
        $('#collaps').trigger('create'); //do not work listwiev without this
        
        if (count == append.length)
            $.mobile.loading('hide');
    }
    
    //click on list element
    function liOnClick(id){
    	console.log(id);
        goToPage('topic.html?id='+id);
    }